<?php

namespace app\common\model;

use think\Model;

class Menu extends Model
{


    protected $table = 'qi_menu';

    protected $autoWriteTimestamp = 'datetime';
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';



    /*
     * 递归创建无级分类
     */
    public function getMenuRecursion($pid = 0){
        $data = $this->where('pid', $pid)->select()->toArray();

        $menuDatas = [];
        foreach($data as $item){
            $children['children'] = $this->getMenuRecursion($item['id']);
            $menuDatas[] = array_merge($item, $children);
        }
        return $menuDatas;
    }




}